package leecode

func minimumDeleteSum(s1 string, s2 string) int {
	hashMap := make(map[byte]int)
	for i := 0; i < len(s1); i++ {
		hashMap[s1[i]]++
	}
	for i := 0; i < len(s2); i++ {
		if _, ok := hashMap[s2[i]]; ok {
			//如果存在
			hashMap[s2[i]]--
			if hashMap[s2[i]] <= 0 {
				delete(hashMap, s2[i])
			}
		} else {
			hashMap[s2[i]]++
		}
	}
	var result int
	for s, count := range hashMap {
		result = result + int(s)*count
	}
	return result
}
